package com.cf.model;

import com.cf.code.core.CField;
import com.cf.code.core.CModel;
import com.cf.code.core.CPage;
import com.cf.code.core.FieldType;
import com.cf.crud.entity.BaseEntity;

import javax.persistence.*;
import java.util.Date;

/**
 * boot-shop-SKU
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/8/16 下午 03:09
 */
@Entity
@Table(name = "sku")
@CModel(pages = {
        @CPage(title = "sku", path = "sku", templateName = "list.ftl", outPutName = "list.ftl"),
        @CPage(title = "sku", path = "sku", templateName = "add.ftl", outPutName = "add.ftl"),
        @CPage(title = "sku", path = "sku", templateName = "update.ftl", outPutName = "update.ftl")
})
public class SKU extends BaseEntity {

    @CField(lab = "SPU", type = FieldType.SELECT, dataUrl = "/spu/search?name=", selectKey = "name", selectValue = "id")
    @Column(name = "spuId")
    private long spuId;

    @CField(lab = "类目Id", type = FieldType.SELECT, dataUrl = "/category/search?name=", selectKey = "name", selectValue = "id")
    @Column(name = "categoryId")
    private long categoryId;

    @CField(lab = "名字")
    private String name = "";

    @CField(lab = "小标题")
    @Column(name = "subTitle")
    private String subTitle = "";

    @CField(lab = "详情图", type = FieldType.FILE)
    private String imgs = "";

    @CField(lab = "详情", type = FieldType.FULLTEXT)
    private String detail = "";


    @CField(lab = "价格")
    private double price = 0d;


    @CField(lab = "状态", type = FieldType.SELECT, defaultValue = "[{\"name\":\"上架\",\"value\":1},{\"name\":\"下架\",\"value\":-1}]", selectValue = "value", selectKey = "name")
    private int status = SKUStatus.COMMON.getStatus();

    /**
     * 售卖数量
     */

    @CField(lab = "售卖数量", type = FieldType.NUMBER)
    private int stock = 0;

    /**
     * 创建时间
     */
    @Column(name = "addTime")
    @Temporal(TemporalType.DATE)
    private Date addTime = new Date();

    /**
     * 更新时间
     */
    @Column(name = "updateTime")
    @Temporal(TemporalType.DATE)
    private Date updateTime = new Date();

    public long getSpuId() {
        return spuId;
    }

    public void setSpuId(long spuId) {
        this.spuId = spuId;
    }

    public long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(long categoryId) {
        this.categoryId = categoryId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public void setSubTitle(String subTitle) {
        this.subTitle = subTitle;
    }

    public String getImgs() {
        return imgs;
    }

    public void setImgs(String imgs) {
        this.imgs = imgs;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
